
class EmptyStringException implements Exception {
  @override
  String toString() {
    return '字符串参数不能为空';
  }
}

void error(data) {
  if (data is String) {
    if (data == '') throw EmptyStringException();
  }
}

void tryCatchTest() {
  try {
    error('');
  } on EmptyStringException catch (e) {
    print('EmptyStringException: $e');
  } catch (e) {
    print(e);
  } finally {
    print('finally');
  }
}

void main() {
  tryCatchTest();
}
